<template>
  <div class="dashboard-container">
    <div class="app-container">
      <el-button type="primary">+新建目录</el-button>
      <!-- 第一部分 -->
      <el-card class="chose">
        <el-form :inline="true" :model="formInline" class="demo-form-inline">
        <el-form-item label="目录名称">
          <el-select v-model="formInline.subjectID" placeholder="请选择">
            <el-option
             v-for="item in options"
             :key="item.id"
             :label="item.directoryName"
             :value="item.id"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="状态">
          <el-select v-model="formInline.status" placeholder="请选择">
            <el-option
             v-for="item in options"
             :key="item.value"
             :label="item.label"
             :value="item.value"></el-option>

          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button  @click="getName()">清除</el-button>
          <el-button type="primary" >搜索</el-button>
        </el-form-item>
      </el-form>
      </el-card>
      <!-- 第二部分 -->
      <el-card class="two">
        <!-- 表格 -->
        <el-table :data="tableData" style="width: 100% ; margin:0;">
          <el-table-column label="序号">
            <template slot-scope="scope">
              <span style="margin-left: 10px">{{ scope.row.number}}</span>
            </template>
          </el-table-column>
          <el-table-column label="目录名称">
            <template slot-scope="scope">
              <span style="margin-left: 10px">{{ scope.row.date }}</span>
            </template>
          </el-table-column>
          <el-table-column label="创建者">
            <template slot-scope="scope">
              <span style="margin-left: 10px">{{ scope.row.name }}</span>
            </template>
          </el-table-column>
          <el-table-column label="创建日期">
            <template slot-scope="scope">
              <i class="el-icon-time"></i>
              <span style="margin-left: 10px">{{ scope.row.date }}</span>
            </template>
          </el-table-column>
          <el-table-column label="面试题数量">
            <template slot-scope="scope">
              <span style="margin-left: 10px">{{ scope.row.date }}</span>
            </template>
          </el-table-column>

          <el-table-column label="状态">
            <template slot-scope="scope">
              <span style="margin-left: 10px">{{ scope.row.number }}</span>
            </template>
          </el-table-column>
          <el-table-column label="操作">
            <template slot-scope="scope">
              <el-link size="mini" type="primary" @click="handleEdit(scope.$index, scope.row)">修改</el-link>
              <el-link type="primary">禁用</el-link>
              <el-link size="mini" type="primary" @click="handleDelete(scope.$index, scope.row)">删除</el-link>
            </template>
          </el-table-column>
        </el-table>
        <!-- 分页 -->
        <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="currentPage4"
          :page-sizes="[10]"
          :page-size="100"
          layout="total, prev, pager, next ,sizes, jumper"
          :total="400"
        ></el-pagination>
      </el-card>
    </div>
  </div>
</template>

<script>
import status from '@/api/hmmm/constants'
import * as api from '@/api/hmmm/directorys'
export default {
  name: 'DirectorysList',
  data() {
    return {
      formInline: {
          catalogue: null,
          status: null,
          subjectID: null,
          page: 1,
          per_page: 20
        },
        options: [],
      tableData: [
        {
          number: 1,
          date: '2016-05-02',
          name: '王小虎',
          address: '上海市普陀区金沙江路 1518 弄'
        }
      ]
    }
  },
  created() {
    this.getName()
  },
  methods: {
    handleEdit(index, row) {
      console.log(index, row)
    },
    handleDelete(index, row) {
      console.log(index, row)
    },

    handleSizeChange(val) {
      console.log(`每页 ${val} 条`)
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`)
    },
      async getName() {
        const data = await api.list()
        this.options = data.data.items
        console.log(data.data.items)

      }
  }
}
</script>

<style scoped less="">
.el-table {
  text-align: center;
}
.chose {
  margin: 20px 0;
  height: 80px;
  line-height: 30px;
}
.chose span {
  margin-right: 10px;
}
.el-select {
  margin-right: 20px;
}
.two {
  text-align: center;
  width: 100%;
  margin: 0;
  padding: 0;
}
</style>
